<?php 
set_time_limit(0);
include '../c/config.php';
$mysqli = new mysqli('47.110.131.55', $dbuser, 'sxy7788123456', $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
$query=$mysqli->query("SELECT dan FROM `ti` WHERE `step` = '1' ");
$i=0;
$daAn=array();
while ($list=$query->fetch_assoc()){
    $i++;
    $daAn[$i]=$list['dan'];
 }
 var_dump($daAn);
echo "<br /><br />";

$dbhost='121.41.208.81';
$mysqliZ = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
$query=$mysqliZ->query("SELECT * FROM `z_uf` where `fen-dx` IS NULL ORDER BY `id` DESC limit 0,1 ");
 if($query->num_rows>0){
 	 $getU=$query->fetch_assoc();
 	 $uId=$getU['openid'];
 	 $theUserId=$getU['id'];
 	 $fen=0;
 	 
 	 
 	 $dbhost='121.41.208.81';
 	 $mysqliA = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
 	 $queryDan=$mysqliA->query("SELECT * FROM `danxuan` where  uid='".$uId."'  limit 0,1 ");
 	 if($queryDan->num_rows>0){
 	     echo 'a -------------------------';
 	     $tmpFen=0;
 	     $getDan=$queryDan->fetch_assoc();
 	     $getyhtj=json_decode($getDan['yhtj'],true);
 	     //var_dump($getyhtj);
 	     echo "<br /><br />";
 	     foreach ($getyhtj as  $k=>$v) {
 	         echo $k,'---',$v,'---',$daAn[$k];
 	         
 	         if($v  == $daAn[$k]){
 	             echo "----dui";
 	             $tmpFen++;
 	         }
 	         echo "<br />";
 	     }
 	     
 	     echo 'a ------------------------- end';
 	     echo "<br /><br />";
 	 }
 	 $mysqliA->close();
 	 if($fen <  $tmpFen){
 	     $fen=$tmpFen;
 	 }
 	 
 	 
 	 
 	 
 	 $mysqliA=$queryDan=NULL;
 	 $dbhost='121.41.216.144';
 	 $mysqliA = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
 	 $queryDan=$mysqliA->query("SELECT * FROM `danxuan` where  uid='".$uId."'  limit 0,1 ");
 	 if($queryDan->num_rows>0){
 	     echo 'b -------------------------';
 	     $tmpFen=0;
 	     $getDan=$queryDan->fetch_assoc();
 	     $getyhtj=json_decode($getDan['yhtj'],true);
 	     //var_dump($getyhtj);
 	     echo "<br /><br />";
 	     foreach ($getyhtj as  $k=>$v) {
 	         echo $k,'---',$v,'---',$daAn[$k];
 	         
 	         if($v  == $daAn[$k]){
 	             echo "----dui";
 	             $tmpFen++;
 	         }
 	         echo "<br />";
 	     }
 	     
 	     echo 'b ------------------------- end';
 	     echo "<br /><br />";
 	 }
 	 $mysqliA->close();
 	 if($fen <  $tmpFen){
 	     $fen=$tmpFen;
 	 }
 	 
 	  
 	 $mysqliA=$queryDan=NULL;
 	 $dbhost='121.41.221.25';
 	 $mysqliA = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
 	 echo "SELECT * FROM `danxuan` where  uid='".$uId."'  limit 0,1 ";
 	 $queryDan=$mysqliA->query("SELECT * FROM `danxuan` where  uid='".$uId."'  limit 0,1 ");
 	 if($queryDan->num_rows>0){
 	     echo 'c -------------------------';
 	     $tmpFen=0;
 	     $getDan=$queryDan->fetch_assoc();
 	     $getyhtj=json_decode($getDan['yhtj'],true);
 	     //var_dump($getyhtj);
 	     echo "<br /><br />";
 	     foreach ($getyhtj as  $k=>$v) {
 	         echo $k,'---',$v,'---',$daAn[$k];
 	         
 	         if($v  == $daAn[$k]){
 	             echo "----dui";
 	             $tmpFen++;
 	         }
 	         echo "<br />";
 	     }
 	     
 	     echo 'c ------------------------- end';
 	 }
 	 if($fen <  $tmpFen){
 	     $fen=$tmpFen;
 	 }
 	 
 	 echo "<br /><br />";
 	 echo 'fen: ',$fen;
 	 $mysqliZ->query("update `z_uf` set `fen-dx`=".$fen."  where id='".$theUserId."' ");
    
 }

 $mysqliZ->close();

 
 echo '
<script>
window.setTimeout(function(){
window.location.reload();
}, 10);
</script>
     
';

exit;
?>


TRUNCATE danxuan;
TRUNCATE duoxuan;
TRUNCATE pan;
TRUNCATE uf;





